
#include "process.h"
#include "commonfunctions.h"

#include <unistd.h>
#include <iostream>
#include <sys/wait.h>
#include <string.h>
#include <stdlib.h>

using namespace std;

Process::Process(int id)
		: m_id(id) {

	// empty

}


void Process::run(char* const* args) {

	//CommonFunctions::exitOnError(fdr < 0 || fdw < 0);
	CommonFunctions::exitOnError(-1 == execvp(args[0], args));
}


int Process::getId() const {

	return m_id;

}


int Process::getState() {

	return 0;

}


int Process::waitFor() const {

	int status;
	waitpid(m_id, &status, 0);

	return status;

}
